﻿using System.Runtime.Caching;
using System;

namespace Tables
{
	class FreeList : IDisposable
	{
		public FreeList ()
		{
			//_p = new Link();
		}

		public void Purge ()
		{
		}

		public Link NewLink ()
		{
			if (_p != null) {
				var mem = _p;
				_p = _p.Next ();
				return mem;
			} else {
				return new Link ();
			}
		}

		public void Recycle (Link link)
		{
		}

		public void Dispose ()
		{
			Dispose (true);
			GC.SuppressFinalize (this);
		}

		protected virtual void Dispose (bool disposing)
		{
			if (!_disposed) {
				if (disposing) {
					//disposed managed resource
                    
				}
				// release unmanaged resource
			}
			_disposed = true;

			// if available, call to base class
			// base.Dispose(disposing);
		}

		private bool _disposed = false;
		private Link _p;
	}
}